package com.scvtc.controller.common;

import com.scvtc.domain.ResResult;
import com.scvtc.domain.dto.common.SystemLoginUser;
import com.scvtc.domain.dto.common.SystemUserLoginDto;
import com.scvtc.service.system.SystemUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Description: 系统用户登录控制层
 * @Author: yiFei
 * @date: 2022/4/13 20:03
 */

@Api(tags = "用户管理(SystemUser)")
@RestController
public class SystemUserLoginController {

    private static final Logger log = LoggerFactory.getLogger(SystemUserLoginController.class);
    @Autowired
    private SystemUserService userService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public ResResult<Map<String, Object>> login(@RequestBody SystemUserLoginDto systemUser) {
        return userService.login(systemUser);
    }

    @ApiOperation("用户详情信息")
    @GetMapping("/user/info")
    public ResResult<SystemLoginUser> userInfo() {
        return userService.userInfo();
    }

    @ApiOperation("用户登出")
    @PostMapping("/logout")
    public ResResult<String> logout() {
        return userService.logout();
    }
}
